﻿using Business.WPF;
using Presenters.WPF.Views;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Presenters.WPF
{
    public class SearchClassroomPresenter
    {
        public ISearchClassroom view { get; set; }


        public SearchClassroomPresenter(ISearchClassroom view)
        {
            this.view = view;            
        }

        public void SearchClassroomRealTime()
        {
            if (this.view.realTimeSearch == true)
            {
                SearchClassroom();
            }
        }

        public void SearchClassroom()
        {            
            SearchByCode();            
        }

        public void SearchByCode()
        {
            try
            {
                SearchClassroomManager ssn = new SearchClassroomManager();
                this.view.results = ssn.SearchByCode(this.view.searchFilter);                
            }
            catch (Exception ex)
            {
                this.view.message = "Error -> " + ex.Message;
            }
        }

    }
}
